//table头信息 不变
var cm_columnData = [
    {"Width": "7%", "ColumnName": "ID"},
    {"Width": "7%", "ColumnName": "短信批次"},
    {"Width": "8%", "ColumnName": "客户名称"},
    {"Width": "7%", "ColumnName": "责任人"},
    {"Width": "7%", "ColumnName": "客户类型"},
    {"Width": "7%", "ColumnName": "客户等级"},
    {"Width": "7%", "ColumnName": "联系人"},
    {"Width": "7%", "ColumnName": "手机号"},
    {"Width": "8%", "ColumnName": "身份证号"},
    {"Width": "7%", "ColumnName": "来源"},
    {"Width": "7%", "ColumnName": "所属行业"},
    {"Width": "7%", "ColumnName": "提交时间"},
    {"Width": "7%", "ColumnName": "状态"},
    //{"Width": "7%", "ColumnName": "重新提交"}
];

//短信审核分页函数
var gotoPage = function (index) {
    //TODO Change Url
    var url = webPath + "/crm/1";
    var messageSubmitter = $("#messageSubmitter").val();
    var messageBatch = $("#messageBatch").val();
    var messageStatus = $("#messageStatus").val();
    //TODO change data key name
    var postData = {
        "pageSize": pageSize, "pageNumber": index,
        "messageSubmitter": messageSubmitter, "messageBatch": messageBatch, "messageStatus": messageStatus
    };
    var options = {"passArguments": index}
    postAjax(url, postData, gotoPageSuccess, options);
};

var gotoPageSuccess = function (result, passArguments) {
    //TODO remove
    var result = '{"totalNumber":3,"list":[{"customerId":"22", "customerName":"张三", "customerGrade":"潜在客户",' +
        '"idNumber":"333333333333333333","recordTime":"2015-6-9","contact":"李四",' +
        '"responsiblePerson":"责任人","customerType":"生产企业","source":"网站注册","phoneNumber":"111111111",' +
        '"industry":"钢铁","messageBatches":"2","status":"驳回"}]}';

    var columnList = ["customerId", "messageBatches", "customerName", "responsiblePerson", "customerType", "customerGrade", "contact",
        "phoneNumber", "idNumber", "source", "industry", "recordTime", "status"];

    cleanTableAndPage("messageInfoTable");
    var jsonData = $.parseJSON(result);
    //画table
    $("#messageInfoTable").MakeTable(false, cm_columnData, jsonData.list, tableClass, columnList);
    //画分页
    $("#messageInfoTable").after(comPagination(passArguments, pageSize, jsonData.totalNumber, "gotoPage", "messageInfoP"));
}

//查询按钮行为
$('#searchCRecordBtn').click(function () {
    gotoPage(1);
});

//获取id 方便提交 TODO Change
var getContectRecordId = function (that) {
    return that.closest("tr").find("td div")[1].innerHTML;
}